<?php 
/**
 * @todo 小说封面,简介,基本信息
 * @author 马超
 */
define('_VIEW_MODEL_','default');
require_once("./init.php");
$bookId = isset($_GET['bid'])?(int)$_GET['bid']:errorPrompt('param_error','/');
$bookInfo = $db->getRow("select * from {$telper}novel where id = '$bookId'");
if(empty($bookInfo))errorPrompt('novel_not_exist','/'); //小说不存在


$filePath            = getNovelPath($bookId);
$fileContent         = file_get_contents($filePath);
$fileContent         = nl2br($fileContent); //带回车换行的内容

$pageSize            = 500; //每页显示记录数
$fileLen			 = function_exists("mb_substr")?mb_strlen($fileContent, 'utf-8'):strlen($fileContent);
$page				 = isset($_GET['page'])?(int)$_GET['page']:1;
$startLen			 = (min($page,ceil($fileLen/$pageSize))-1)*$pageSize;
$firstContent        = csubstr($fileContent,$startLen,500);
require_once INC.'/pageclass.php';
new Page($fileLen,$pageSize,$smartyObj);

$bookInfo['summary'] =  truncateutf8($bookInfo['summary'],50,'');
$smartyObj->assign('bookinfo',$bookInfo);
header("Content-type:text/vnd.wap.wml;charset=utf-8");
$smartyObj->display('bookshow.tpl');
?>